package com.example;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.example.service.UserService;

public class App {
    public static void main(String[] args) {
        System.out.println("=== Spring扫描配置演示程序 ===");
        
        // 1. 加载Spring配置文件
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        
        // 2. 从容器中获取Bean
        UserService userService = (UserService) context.getBean("userService");
        
        // 3. 使用Bean 
        System.out.println("初始用户数: " + userService.getUserCount());
        
        // 添加用户
        userService.addUser("张三");
        userService.addUser("李四");
        userService.addUser("王五");
        
        // 获取用户信息
        System.out.println(userService.getUserInfo());
        System.out.println("总用户数: " + userService.getUserCount());
        
        System.out.println("=== 程序执行完成 ===");
    }
}